﻿<catel:UserControl x:Class="Catel.Examples.SL4.PersonApplication.Views.MainPage"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:ToolkitControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
                   xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                   xmlns:catel="http://catel.codeplex.com">

    <!-- Resources -->
    <catel:UserControl.Resources>
    </catel:UserControl.Resources>

    <!-- Content -->
    <ToolkitControls:DockPanel x:Name="LayoutRoot" Background="White" LastChildFill="True">
        <!-- Details and actions -->
        <StackPanel ToolkitControls:DockPanel.Dock="Right" Orientation="Vertical">
            <!-- Details -->
            <!--<GroupBox Header="Details">

                </GroupBox>-->

            <!-- Buttons -->
            <ToolkitControls:WrapPanel>
                <!-- Added -->
                <Button Command="{Binding Add}" Style="{StaticResource ImageButtonStyle}">
                    <Image Source="/Catel.Examples.SL4.PersonApplication;component/Resources/Images/add.png"/>
                </Button>

                <!-- Edit -->
                <Button Command="{Binding Edit}" Style="{StaticResource ImageButtonStyle}">
                    <Image Source="/Catel.Examples.SL4.PersonApplication;component/Resources/Images/edit.png"/>
                </Button>

                <!-- Remove -->
                <Button Command="{Binding Remove}" Style="{StaticResource ImageButtonStyle}">
                    <Image Source="/Catel.Examples.SL4.PersonApplication;component/Resources/Images/delete.png"/>
                </Button>
            </ToolkitControls:WrapPanel>
        </StackPanel>

        <!-- List of persons -->
        <ListBox ToolkitControls:DockPanel.Dock="Left" x:Name="listBox" ItemsSource="{Binding PersonCollection}" SelectedItem="{Binding SelectedPerson, Mode=TwoWay}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <i:Interaction.Behaviors>
                            <catel:DoubleClickToCommand Command="{Binding ElementName=listBox, Path=DataContext.Edit}" />
                        </i:Interaction.Behaviors>
                        
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding FirstName}" />
                            <TextBlock Text="{Binding MiddleName}" />
                            <TextBlock Text="{Binding LastName}" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </ToolkitControls:DockPanel>
</catel:UserControl>
